/***************************************************************************
 *   Copyright (C) 2008 by BogDan Vatra                                    *
 *   bogdan@licentia.eu                                                    *
 *                                                                         *
 *   This program is free software: you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/
#include <QtCore>

#include "masiniplugin.h"
#include "masini.h"

inline void initMyResource()
{
	Q_INIT_RESOURCE(masini);
}

MasiniPlugin::MasiniPlugin(QObject *parent):QObject(parent)
{
	initMyResource();
}

KontAMabilWindow * MasiniPlugin::createWidget(QWidget * parent)
{
	Masini * m_widget= new Masini(parent);
	m_widget->setObjectName(name());
	return m_widget;
}

QIcon MasiniPlugin::icon(const QString &)
{
	return QIcon(":/masini/masini.png");
}

QString MasiniPlugin::querys()
{
	QFile f(":/masini/sql.xml");
	if (!f.open(QIODevice::ReadOnly))
		return QString();
	QString querys=f.readAll();
	f.close();
	return querys;
}

int MasiniPlugin::order()
{
	return 1;
}

int MasiniPlugin::menuGroup(const QString &)
{
	return 1;
}

QString MasiniPlugin::toolTip(const QString &)
{
	return "Actualizare masini";
}

bool MasiniPlugin::add(QWidget * /*parent*/, const QString & addStr, QString * result, qint64 * id)
{
	bool res=false;
	Masini * widget = new Masini;//(parent);
	res=widget->addMasina(addStr, result, id);
	delete widget;
	return res;
}

QString MasiniPlugin::name()
{
	return "masini";
}

QString MasiniPlugin::version()
{
	return "0.1";
}

QString MasiniPlugin::depends()
{
	return "model";
}

QString MasiniPlugin::recommends()
{
	return "Vehicole";
}

QString MasiniPlugin::description(const QString &)
{
	QFile f(":/masini/doc.html");
	if (!f.open(QIODevice::ReadOnly))
		return QString();
	QString doc=f.readAll();
	f.close();
	return doc;
}

QStringList MasiniPlugin::menus()
{
	return QStringList()<<"/FAZ/Actualizare baza/Masini";
}
QStringList MasiniPlugin::showMenus()
{
	return QStringList()<<"FAZ";
}

Q_EXPORT_PLUGIN2(masiniPlugin, MasiniPlugin);
